<template>
	<view class="bgff">
		<view class="pd mt20">
			<view class="xcxzcretrexr">
				<view class=" display-flex pd pt20 pm20" @tap="kmxcxfer=true">
					<view class="cxzcrefsxcre  vertical-center">
						选择员工：
					</view>
					<view class="z6 flex-1 ml20">
						
						{{umzxdsf||'点击选择'}}
					</view>
					<view class=" vertical-center">
						<text class="iconfont icon-rightyou fz26"></text>
					</view>
				</view>
				<view class=" display-flex pd pt20 pm20 btm">
					<view class="cxzcrefsxcre  vertical-center">
						合同名称：
					</view>
					<view class="z6 flex-1 ml20">
						<input v-model="fomData.content" type="text"  class="w100 fz32" placeholder="请输入" />
					</view>
				</view>

				<view class="pt20 pm10 display-flex fz30 z3 btm pd">
					上传的资料({{jdfdsrt.length}}/5)
				</view>
				<view class="xcxzcsgfgfdgr mt20 pm20 pd">
					<view class="pr czxcsderexcr" v-for="(sd,idx) in jdfdsrt">
						<image :src="sd" class="w100 h100 cz" mode="aspectFill"></image>
						<text class="iconfont icon-14CIRCLE clofdfdtrtrt" @tap="jjmxdsfsd"></text>
					</view>
					<view class="czxcsderexcr vertical-center" @tap="kxmcfdf" v-if="jdfdsrt.length<5">
						<text class="iconfont icon-zhaopian xzcertrxcr"></text>
					</view>
				</view>
			</view>
		</view>
	</view>
	<view class="mt100 pd">
		<button type="primary" class="fz32" @tap="tijixcrty">确认</button>
	</view>
	<view class="czxctretrcxt vertical-bottom" v-if="kmxcxfer">
		<view class="w100 bgff">
			<view class="pd pt20 pm20 display-flex">
				<view class=" flex-1 vertical-center tl">
					<text class="kkxczxerwt">请选择员工</text>
				</view>
				<view class="">
					<text class="iconfont icon-14CIRCLE red fz40 cz" @tap="kmxcxfer=false"></text>
				</view>
			</view>
			<view class="btm pd pt20 pm20 cxzczxtrtrecst">
				<employeeList @success="getdatase"></employeeList>
			</view>
		</view>
	</view>
</template>
<script lang="ts" setup>
	import { ref } from "vue"
	import { upImg, hf, yzphone, callBack, zidianall, dxrequest } from "@/util/index.js"
	import { onLoad } from "@dcloudio/uni-app"
	import employeeList from "@/components/employeeList.vue"
	const jdfdsrt = ref([])
	const kmxcxfer= ref(false)
	const umzxdsf = ref("")
	const fomData = ref({
		userId:"",
		content:"",//合同名称
		imgUrl:"",
		contentType:6
	})
	
	const jjmxdsfsd = (idx) => {
		jdfdsrt.value.splice(idx, 1)
	}
	const kxmcfdf = async () => {
		const dhsd = await upImg()
		jdfdsrt.value.push(dhsd.imgurl)
	}
	// /api/userdata
	const getdatase = (data)=>{
		umzxdsf.value = data.realName
		fomData.value.userId = data.id
		kmxcxfer.value = false
	}
	const tijixcrty = async()=>{
		fomData.value.imgUrl = jdfdsrt.value.join(",")
		if(!fomData.value.userId){
			uni.showToast({
				title:"请选择员工",
				icon:"none"
			})
			return
		}
		if(!fomData.value.content){
			uni.showToast({
				title:"请输入合同名称",
				icon:"none"
			})
			return
		}
		if(!fomData.value.imgUrl){
			uni.showToast({
				title:"请上传资料",
				icon:"none"
			})
			return
		}
		const {data} =  await dxrequest("/api/userdata",fomData.value,"post")
		callBack()
	}
</script>

<style scoped>
	
</style>